package com.wuyong.talkstructure.chapter3;

import java.util.*;

public class SqlList<E> {

    private int MAXSIZE = 20;
    private E[] data;
    private int size;
    public SqlList(){

        data = (E[]) new Object[MAXSIZE];
        size = 0;

    }

    public E getElement(int i) {
        if (size == 0 || i < 1 || i > data.length)
            throw new IllegalArgumentException("非法参数！");

        return data[i - 1];
    }

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("wew1");
        list.add("wew2");
        list.add("wew3");
        list.add("wew4");
        System.out.println("args = [" + list + "]");
        Iterator<String> it = list.iterator();
        it.next();
        it.remove();
         System.out.println("args = [" + list + "]");

        Set<String> set = new HashSet<>();
        set.add("aaa3");
        set.add("aaa1");
        set.add("aaa2");

        set.add("aaa4");

        System.out.println("args = [" + set + "]");

        Iterator<String> it2 = set.iterator();
        System.out.println("args = [" + it2.next() + "]");
        it2.next();
        it2.remove();
        System.out.println("args = [" + set + "]");
    }
}
